package edu.mit.media.fv.components
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;

	public class AQPainter extends MovieClip
	{
		private var down:Boolean = false;
		private var _width:int;
		private var _height:int;
		private var _previousMouseX:int;
		private var _previousMouseY:int;
		public function AQPainter(x:int, y:int, width:int, height:int)
		{
			super();
			
			this.x = x;
			this.y = y;
			this._width = width;
			this._height = height;
			
			this.graphics.beginFill(0xFFFFFF);
			this.graphics.drawRect(0,0,this._width, this._height);
			this.graphics.endFill();
			
			this.graphics.lineStyle(5,0x000000);
			
			this.addEventListener(MouseEvent.MOUSE_DOWN, brushDown);
			this.addEventListener(MouseEvent.MOUSE_UP,brushUp);
			this.addEventListener(MouseEvent.ROLL_OUT, brushUp);
			this.addEventListener(MouseEvent.MOUSE_MOVE, brushDragged);
			
		}
		
		public function brushUp(event:MouseEvent):void{
			if(down){
				this.graphics.lineTo(this.mouseX, this.mouseY);
			}
			this.down = false;
		}
		public function brushDown(event:MouseEvent):void{
			this.graphics.moveTo(this.mouseX, this.mouseY);
			this.down = true;
		}
		public function brushDragged(event:MouseEvent):void{
			if(down){
				this.graphics.lineTo(this.mouseX, this.mouseY);
			}
		}
		public function getImage():void{
			
		}
	}
}